#!/bin/bash

# sed insert command 'i' works just like the append command except
# that it inserts a line before a specific location, instead of 
# after the location 

#-- Insert Line Before Given Location -- 
# syntax: sed '[address] i {the-line-to-insert}' {input-file}

# - insert a new record before line number2 of the test_employee.txt
sed '4 i 100,Jack Johnson,Engineer' ./test_employee.txt
echo -e '\n'

# - insert a new record before the last line of the test_employee.txt
sed '$ i 106,Maritny Hery,Engineer' ./test_employee.txt # use '$' to indicates the last line.
echo -e '\n'

# - insert multiple lines using i command 
sed '/Jason/i\
# new line 1\
# new line 2' ./test_employee.txt



